package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingInteractiveSharing;
import com.ruoyi.ring.service.IRingInteractiveSharingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 互动分享Controller
 * 
 * @author liuwp
 * @date 2025-11-21
 */
@RestController
@RequestMapping("/ring/ring_interactive_sharing")
public class RingInteractiveSharingController extends BaseController
{
    @Resource
    private IRingInteractiveSharingService ringInteractiveSharingService;

    /**
     * 查询互动分享列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_interactive_sharing:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingInteractiveSharing ringInteractiveSharing)
    {
        startPage();
        List<RingInteractiveSharing> list = ringInteractiveSharingService.selectRingInteractiveSharingList(ringInteractiveSharing);
        return getDataTable(list);
    }

    /**
     * 导出互动分享列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_interactive_sharing:export')")
    @Log(title = "互动分享", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingInteractiveSharing ringInteractiveSharing)
    {
        List<RingInteractiveSharing> list = ringInteractiveSharingService.selectRingInteractiveSharingList(ringInteractiveSharing);
        ExcelUtil<RingInteractiveSharing> util = new ExcelUtil<RingInteractiveSharing>(RingInteractiveSharing.class);
        util.exportExcel(response, list, "互动分享数据");
    }

    /**
     * 获取互动分享详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_interactive_sharing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringInteractiveSharingService.selectRingInteractiveSharingById(id));
    }

    /**
     * 新增互动分享
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_interactive_sharing:add')")
    @Log(title = "互动分享", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingInteractiveSharing ringInteractiveSharing)
    {
        return toAjax(ringInteractiveSharingService.insertRingInteractiveSharing(ringInteractiveSharing));
    }

    /**
     * 修改互动分享
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_interactive_sharing:edit')")
    @Log(title = "互动分享", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingInteractiveSharing ringInteractiveSharing)
    {
        return toAjax(ringInteractiveSharingService.updateRingInteractiveSharing(ringInteractiveSharing));
    }

    /**
     * 删除互动分享
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_interactive_sharing:remove')")
    @Log(title = "互动分享", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringInteractiveSharingService.deleteRingInteractiveSharingByIds(ids));
    }
}
